package com.mistoplus.sedona;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListView;

import com.mistoplus.bean.VortextListItem;
import com.mistoplus.sedona.main.MainMenu;

public class VortexListView extends Activity {

	private ImageView mImvMenuMove;
	private ImageView mImvMapView;
	private ImageView mImvListView;
	
	private ListView mLvVortex;
	private VortextListAdapter mAptVortex;
	private List<VortextListItem> mListVortex;
	private Handler mHd;
	private Context mContext;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	    setContentView(R.layout.vortex_list_view);
	    
	    mContext = VortexListView.this;
	    mImvMenuMove = (ImageView)findViewById(R.id.imv_left);
	    mImvMapView = (ImageView)findViewById(R.id.imv_map_view);
	    mImvListView = (ImageView)findViewById(R.id.imv_list_view);
	    
	    mImvMapView.setBackgroundDrawable(getResources().getDrawable(R.drawable.non_map_selected));
	    mImvListView.setBackgroundDrawable(getResources().getDrawable(R.drawable.list_selected));
		
		mImvMenuMove.setOnClickListener(onClickActMove);
		mImvMapView.setOnClickListener(onClickActMove);
		
		mLvVortex = (ListView)findViewById(R.id.lv_vortex_list);
		mLvVortex.setOnItemClickListener(onItemClickVortex);
		mListVortex = getVortexSampleData();
		mAptVortex = new VortextListAdapter(mContext, mHd, mListVortex);
		mLvVortex.setAdapter(mAptVortex);
	}
	
	OnItemClickListener onItemClickVortex = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View v, int position,
				long id) {
			Intent intent = new Intent(VortexListView.this, VortexDetailView.class);
			startActivity(intent);
		}
	};
	OnClickListener onClickActMove = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			if(v.getId() == R.id.imv_left){
				Intent intent = new Intent(VortexListView.this, MainMenu.class);
				startActivity(intent);
				
			}else if(v.getId() == R.id.imv_map_view){
				Intent intent = new Intent(VortexListView.this, VortexMapView.class);
				startActivity(intent);
			}
		}
	};
	
	private List<VortextListItem> getVortexSampleData(){
		mListVortex = new ArrayList<VortextListItem>();
		
		VortextListItem item1 = new VortextListItem("Bell Rock:", "Feeling a Vortex");
		VortextListItem item2 = new VortextListItem("Cathedral Rock:", "Purifying Emotions");
		VortextListItem item3 = new VortextListItem("Airport Mesa:", "Starlight Meditation");
		VortextListItem item4 = new VortextListItem("Oak Creek Canyon:", "Water Sound Self-Healing");
		VortextListItem item5 = new VortextListItem("Capel of The Holy Cross:", "Prayer");
		VortextListItem item6 = new VortextListItem("Schnebly Hill:", "Chakra Light Meditation");
		VortextListItem item7 = new VortextListItem("Fay Canyon:", "Communicating with Trees");
		VortextListItem item8 = new VortextListItem("Boyton Canyon:", "Whole Body Walking");
		
		mListVortex.add(item1);
		mListVortex.add(item2);
		mListVortex.add(item3);
		mListVortex.add(item4);
		mListVortex.add(item5);
		mListVortex.add(item6);
		mListVortex.add(item7);
		mListVortex.add(item8);
		
		return mListVortex;
	}

}
